class PalindromeList {
public:
    bool chkPalindrome(ListNode* A) {
        ListNode* cur = A;
        int flag = 1;
        int sz = 0;
        while (cur)
        {
            sz++;
            cur = cur->next;
        }
        for (int i = 0; i <= sz / 2; i++)
        {
            int countHead = i;
            int countTail = sz - i - 1;
            ListNode* head = A;
            ListNode* tail = A;
            while (countHead--)
            {
                head = head->next;
            }
            while (countTail--)
            {
                tail = tail->next;
            }
            if (tail->val != head->val)
            {
                flag = 0;
            }
        }
        return 1 == flag;
    }
};
